import 'core-js/stable'
import 'regenerator-runtime/runtime'
import Vue from 'vue'
import App from '@/App.vue'
import router from '@/router'
import '@/plugins/axios'
import '@/css/main.css'

import * as utils from '@/utils/utils'
Vue.prototype.utils = utils

import videojs from "video.js"
import "video.js/dist/video-js.css"
Vue.prototype.$video = videojs

import ContextMenu from '@/components/ContextMenu.vue'
Vue.component('context-menu', ContextMenu)

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)

Vue.config.productionTip = false

Vue.directive('clickOut', {
    bind(el, { value }) {
        function clickHandler(e) {
            if (el.contains(e.target)) return
            if (typeof value === 'function') {
                value()
            }
        }
        el.handler = clickHandler
        setTimeout(() => {
            document.addEventListener('click', el.handler)
        }, 0)
    },
    unbind(el) {
        document.removeEventListener('click', el.handler)
    }
})

new Vue({
    router,
    render: h => h(App),
    beforeCreate() {
        Vue.prototype.$bus = this
    }
}).$mount('#app')
